#pragma once
#include "../Primitives/IPrimitive.h"
class ZBuffer
{
public:
	ZBuffer(int w,int h,float farZ = 10000.0);
	~ZBuffer(void);
	inline bool test(int x,int y,float z){
		int i = y * _w + x;
		if (i > 0 && i < _wXh)
		{
			if(z < data[i]){
				data[i] = z;
				return true;
			}else{
				return false;
			}
		}else{
			//fix me: why run to here?
			return false;
		}
	};
	void clearBuffer();
private:
	float* data;
	int _w,_h,_wXh;
	float _farZ;
};

